object test07 {
  def main(args: Array[String]): Unit = {
//    def show():Unit={
//      println("1111")
//    }
//    show()

    def zhengchu(a:Int):Unit={
      println(s"从1到${a}之间能够整除${a}的数是：")
      for (i<-1 to a if a%i==0){
        print(i+"\t")
      }
      println
    }
    zhengchu(30)

    def max(a:Int,b:Int):Int={
      if (a>b){
       a
      }else{
       b
      }
    }
    println(max(22,33))

    def runnian(a:Int):Boolean={
      if ((a%4==0 && a%100!=0) || (a%400==0)){
        true
      }else{
        false
      }
    }
    var a=2021
    if (runnian(a)){
      println(a+"年二月有29天")
    }else{
      println(a+"年二月有28天")
    }


    def pjf(a:Double*):Double={
      var sum:Double = 0
//      println(a)
      for(i <- a){
        sum+=i
      }
      sum/a.length
    }
    println(pjf(1,2,3,4,5))

    def show3(name:String)="你好"+name
    println(show3("jack"))

    def show4()="你好rose"
    println(show4())

    def show5="你好jerry"
    println(show5)

//  name可以用_代替
//    (name:String)=>"你好"+name


    var lambda1=(a:Int,b:Int)=>if(a>b) a else b
    println(lambda1(5,7))

    var lambda2=()=>"一句话"
    println(lambda2())

    var lambda3=(a:Int)=>a % 3
    println(lambda3(4))

  }
}
